const DB = require('../../utils/db');

module.exports = {
	status: async (id) => {
		let [list] = await DB.query(`select * from t_hole where id = ?`, [id]);
		let status = list[0].status == 1 ? 2 : 1;
		let data = await DB.query('update t_hole set status = ? where id = ?', [status, id]);
		return data;
	},
	list: async (pageNum, pageSize, keywords) => {
		let [allList] = await DB.query(`select *  from t_hole where name like '%${keywords}%'`);

		let arr = [(pageNum - 1) * pageSize, pageSize];
		let [list] = await DB.query(`select *,date_format(createTime,'%Y-%m-%d %H:%i:%s') createTime   from t_hole where name like '%${keywords}%' limit ?,?`, arr);
		return { data: list, total: allList.length };
	},
	del: async (ids) => {
		let data = await DB.query('delete from t_hole where id in (?)', [ids]);
		return data;
	}
};
